package com.yanqu.road.server.cmd.activity.luckydraw;

import com.yanqu.road.entity.player.UserRealReward;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.LuckyDrawProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.RealRewardModule;
import com.yanqu.road.server.pb.LuckyDrawPb;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

import java.util.List;

@Cmd(code = GameProtocol.S_LUCKY_DRAW_GET_REAL_REWARD, desc = "")
public class LuckyDrawGetRealRewardCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        List<UserRealReward> list = player.getModule(RealRewardModule.class).getNoExpireUserRealRewardList();

        LuckyDrawProto.LuckyDrawGetRealRewardRespMsg.Builder builder = LuckyDrawProto.LuckyDrawGetRealRewardRespMsg.newBuilder();
        for (UserRealReward reward : list) {
            builder.addRealReward(LuckyDrawPb.parseLuckyDrawRealRewardMsg(reward));
        }
        player.sendPacket(ClientProtocol.U_LUCKY_DRAW_GET_REAL_REWARD, builder);
    }

    @Override
    public void sendData(GamePlayer player) {
    }

}
